﻿<form class="layui-form layui-form-pane" lay-filter="">
    <div class="layui-form-item">
        <label class="layui-form-label">所属园区</label>
        <div class="layui-input-inline">
            <select id="ParkID" name="ParkID" lay-filter="ParkID" lay-verify="required">
                <option value="">请选择</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">仓库类型</label>
        <div class="layui-input-inline">
            <select id="StoreTypeID" name="StoreTypeID" lay-filter="StoreTypeID" lay-verify="required">
                <option value="">请选择</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">仓库编号</label>
        <div class="layui-input-inline">
            <input type="text" name="Code" autocomplete="off" class="layui-input" lay-verify="required" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">仓库面积</label>
        <div class="layui-input-inline">
            <input type="text" name="Area" autocomplete="off" class="layui-input" lay-verify="number" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">仓库长度</label>
        <div class="layui-input-inline">
            <input type="text" name="Length" autocomplete="off" class="layui-input" lay-verify="number" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">仓库宽度</label>
        <div class="layui-input-inline">
            <input type="text" name="Width" autocomplete="off" class="layui-input" lay-verify="number" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">仓库高度</label>
        <div class="layui-input-inline">
            <input type="text" name="Height" autocomplete="off" class="layui-input" lay-verify="number" />
        </div>
    </div>
    <div class="layui-form-item" style="text-align:center;">
        <button class="layui-btn" lay-submit lay-filter="save">保存</button>
        <button class="layui-btn" id="cancel">取消</button>
    </div>
</form>
<script type="text/javascript">
    layui.use(['form', 'jquery'], function () {
        var form = layui.form;
        var $ = layui.jquery;
        var parkList = @Html.Raw(ViewBag.ParkList);
        $(parkList).each(function (index, item) {
            $("#ParkID").append("<option value='" + item.ID + "'>" + item.Code + "</option>");
        });
        form.render("select");
        $.ajax({
            url: '/Resource/StoreType/SelectList',
            success: function (res) {
                if (res.count > 0) {
                    $(res.data).each(function (index, item) {
                        $("#StoreTypeID").append("<option value='" + item.value + "'>" + item.text + "</option>");
                    });
                    form.render("select");
                }
            }
        });
        form.on("submit(save)", function (formdata) {
            $.ajax({
                url: 'Add',
                data: formdata.field,
                success: function (res) {
                    layer.alert(res.msg, function (index) {
                        layer.close(index);
                        if (res.count > 0) {
                            parent.layer.closeAll();
                        }
                    })
                }
            });
            return false;
        })
        $("#cancel").click(function () {
            parent.layer.closeAll();
        })
    })
</script>